package queue

import "errors"

type SimpleQueen struct{
	Cap int //容量
	Content []interface{} //数组

}
func NewSimpleQueue(capaciity int) *SimpleQueen {
	q := new(SimpleQueen)
	q.Cap=capaciity
	q.Content = make([]interface{},0)
	return q
}

func (s *SimpleQueen)Put(p interface{})  {

	if len(s.Content)>=s.Cap {
		s.Content=append([]interface{}{p},s.Content[0:s.Cap-1]...)
	}else {

		s.Content=append([]interface{}{p},s.Content[:len(s.Content)]...)
	}

}
func(s *SimpleQueen)Get()[]interface{}{

	return s.Content

}

func(s *SimpleQueen)GetFirst()(interface{},error){

	if len(s.Content)>0 {
		return s.Content[0],nil
	}else{
		return nil,errors.New("空")
	}

}
func(s *SimpleQueen)CoverFirst(a interface{}){

	if len(s.Content)>0 {
		s.Content[0]=a
	}else{
		s.Content=[]interface{}{a}

	}

}